/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package com.googlecode.mailnet.emf.netmodel.impl;

import com.googlecode.mailnet.emf.netmodel.DistributionModel;
import com.googlecode.mailnet.emf.netmodel.LinkModel;
import com.googlecode.mailnet.emf.netmodel.NetmodelPackage;
import com.googlecode.mailnet.emf.netmodel.NodeModel;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Link Model</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.LinkModelImpl#getSource <em>Source</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.LinkModelImpl#getDestination <em>Destination</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.LinkModelImpl#getCapacityDistribution <em>Capacity Distribution</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.LinkModelImpl#getPackageCorruptionProbability <em>Package Corruption Probability</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.LinkModelImpl#getDelay <em>Delay</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.LinkModelImpl#getFailureProbability <em>Failure Probability</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.LinkModelImpl#getFailureDurationDistribution <em>Failure Duration Distribution</em>}</li>
 *   <li>{@link com.googlecode.mailnet.emf.netmodel.impl.LinkModelImpl#getName <em>Name</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class LinkModelImpl extends EObjectImpl implements LinkModel {
	/**
	 * The cached value of the '{@link #getSource() <em>Source</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSource()
	 * @generated
	 * @ordered
	 */
	protected NodeModel source;

	/**
	 * The cached value of the '{@link #getDestination() <em>Destination</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDestination()
	 * @generated
	 * @ordered
	 */
	protected NodeModel destination;

	/**
	 * The cached value of the '{@link #getCapacityDistribution() <em>Capacity Distribution</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCapacityDistribution()
	 * @generated
	 * @ordered
	 */
	protected DistributionModel capacityDistribution;

	/**
	 * The default value of the '{@link #getPackageCorruptionProbability() <em>Package Corruption Probability</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPackageCorruptionProbability()
	 * @generated
	 * @ordered
	 */
	protected static final double PACKAGE_CORRUPTION_PROBABILITY_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getPackageCorruptionProbability() <em>Package Corruption Probability</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPackageCorruptionProbability()
	 * @generated
	 * @ordered
	 */
	protected double packageCorruptionProbability = PACKAGE_CORRUPTION_PROBABILITY_EDEFAULT;

	/**
	 * The default value of the '{@link #getDelay() <em>Delay</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDelay()
	 * @generated
	 * @ordered
	 */
	protected static final int DELAY_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getDelay() <em>Delay</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDelay()
	 * @generated
	 * @ordered
	 */
	protected int delay = DELAY_EDEFAULT;

	/**
	 * The default value of the '{@link #getFailureProbability() <em>Failure Probability</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFailureProbability()
	 * @generated
	 * @ordered
	 */
	protected static final double FAILURE_PROBABILITY_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getFailureProbability() <em>Failure Probability</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFailureProbability()
	 * @generated
	 * @ordered
	 */
	protected double failureProbability = FAILURE_PROBABILITY_EDEFAULT;

	/**
	 * The cached value of the '{@link #getFailureDurationDistribution() <em>Failure Duration Distribution</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFailureDurationDistribution()
	 * @generated
	 * @ordered
	 */
	protected DistributionModel failureDurationDistribution;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected LinkModelImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return NetmodelPackage.Literals.LINK_MODEL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NodeModel getSource() {
		if (source != null && source.eIsProxy()) {
			InternalEObject oldSource = (InternalEObject)source;
			source = (NodeModel)eResolveProxy(oldSource);
			if (source != oldSource) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, NetmodelPackage.LINK_MODEL__SOURCE, oldSource, source));
			}
		}
		return source;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NodeModel basicGetSource() {
		return source;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSource(NodeModel newSource) {
		NodeModel oldSource = source;
		source = newSource;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.LINK_MODEL__SOURCE, oldSource, source));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NodeModel getDestination() {
		if (destination != null && destination.eIsProxy()) {
			InternalEObject oldDestination = (InternalEObject)destination;
			destination = (NodeModel)eResolveProxy(oldDestination);
			if (destination != oldDestination) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, NetmodelPackage.LINK_MODEL__DESTINATION, oldDestination, destination));
			}
		}
		return destination;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NodeModel basicGetDestination() {
		return destination;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDestination(NodeModel newDestination) {
		NodeModel oldDestination = destination;
		destination = newDestination;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.LINK_MODEL__DESTINATION, oldDestination, destination));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DistributionModel getCapacityDistribution() {
		if (capacityDistribution != null && capacityDistribution.eIsProxy()) {
			InternalEObject oldCapacityDistribution = (InternalEObject)capacityDistribution;
			capacityDistribution = (DistributionModel)eResolveProxy(oldCapacityDistribution);
			if (capacityDistribution != oldCapacityDistribution) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, NetmodelPackage.LINK_MODEL__CAPACITY_DISTRIBUTION, oldCapacityDistribution, capacityDistribution));
			}
		}
		return capacityDistribution;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DistributionModel basicGetCapacityDistribution() {
		return capacityDistribution;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCapacityDistribution(DistributionModel newCapacityDistribution) {
		DistributionModel oldCapacityDistribution = capacityDistribution;
		capacityDistribution = newCapacityDistribution;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.LINK_MODEL__CAPACITY_DISTRIBUTION, oldCapacityDistribution, capacityDistribution));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getPackageCorruptionProbability() {
		return packageCorruptionProbability;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPackageCorruptionProbability(double newPackageCorruptionProbability) {
		double oldPackageCorruptionProbability = packageCorruptionProbability;
		packageCorruptionProbability = newPackageCorruptionProbability;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.LINK_MODEL__PACKAGE_CORRUPTION_PROBABILITY, oldPackageCorruptionProbability, packageCorruptionProbability));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getDelay() {
		return delay;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDelay(int newDelay) {
		int oldDelay = delay;
		delay = newDelay;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.LINK_MODEL__DELAY, oldDelay, delay));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public double getFailureProbability() {
		return failureProbability;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFailureProbability(double newFailureProbability) {
		double oldFailureProbability = failureProbability;
		failureProbability = newFailureProbability;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.LINK_MODEL__FAILURE_PROBABILITY, oldFailureProbability, failureProbability));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DistributionModel getFailureDurationDistribution() {
		if (failureDurationDistribution != null && failureDurationDistribution.eIsProxy()) {
			InternalEObject oldFailureDurationDistribution = (InternalEObject)failureDurationDistribution;
			failureDurationDistribution = (DistributionModel)eResolveProxy(oldFailureDurationDistribution);
			if (failureDurationDistribution != oldFailureDurationDistribution) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, NetmodelPackage.LINK_MODEL__FAILURE_DURATION_DISTRIBUTION, oldFailureDurationDistribution, failureDurationDistribution));
			}
		}
		return failureDurationDistribution;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DistributionModel basicGetFailureDurationDistribution() {
		return failureDurationDistribution;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFailureDurationDistribution(DistributionModel newFailureDurationDistribution) {
		DistributionModel oldFailureDurationDistribution = failureDurationDistribution;
		failureDurationDistribution = newFailureDurationDistribution;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.LINK_MODEL__FAILURE_DURATION_DISTRIBUTION, oldFailureDurationDistribution, failureDurationDistribution));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, NetmodelPackage.LINK_MODEL__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case NetmodelPackage.LINK_MODEL__SOURCE:
				if (resolve) return getSource();
				return basicGetSource();
			case NetmodelPackage.LINK_MODEL__DESTINATION:
				if (resolve) return getDestination();
				return basicGetDestination();
			case NetmodelPackage.LINK_MODEL__CAPACITY_DISTRIBUTION:
				if (resolve) return getCapacityDistribution();
				return basicGetCapacityDistribution();
			case NetmodelPackage.LINK_MODEL__PACKAGE_CORRUPTION_PROBABILITY:
				return new Double(getPackageCorruptionProbability());
			case NetmodelPackage.LINK_MODEL__DELAY:
				return new Integer(getDelay());
			case NetmodelPackage.LINK_MODEL__FAILURE_PROBABILITY:
				return new Double(getFailureProbability());
			case NetmodelPackage.LINK_MODEL__FAILURE_DURATION_DISTRIBUTION:
				if (resolve) return getFailureDurationDistribution();
				return basicGetFailureDurationDistribution();
			case NetmodelPackage.LINK_MODEL__NAME:
				return getName();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case NetmodelPackage.LINK_MODEL__SOURCE:
				setSource((NodeModel)newValue);
				return;
			case NetmodelPackage.LINK_MODEL__DESTINATION:
				setDestination((NodeModel)newValue);
				return;
			case NetmodelPackage.LINK_MODEL__CAPACITY_DISTRIBUTION:
				setCapacityDistribution((DistributionModel)newValue);
				return;
			case NetmodelPackage.LINK_MODEL__PACKAGE_CORRUPTION_PROBABILITY:
				setPackageCorruptionProbability(((Double)newValue).doubleValue());
				return;
			case NetmodelPackage.LINK_MODEL__DELAY:
				setDelay(((Integer)newValue).intValue());
				return;
			case NetmodelPackage.LINK_MODEL__FAILURE_PROBABILITY:
				setFailureProbability(((Double)newValue).doubleValue());
				return;
			case NetmodelPackage.LINK_MODEL__FAILURE_DURATION_DISTRIBUTION:
				setFailureDurationDistribution((DistributionModel)newValue);
				return;
			case NetmodelPackage.LINK_MODEL__NAME:
				setName((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case NetmodelPackage.LINK_MODEL__SOURCE:
				setSource((NodeModel)null);
				return;
			case NetmodelPackage.LINK_MODEL__DESTINATION:
				setDestination((NodeModel)null);
				return;
			case NetmodelPackage.LINK_MODEL__CAPACITY_DISTRIBUTION:
				setCapacityDistribution((DistributionModel)null);
				return;
			case NetmodelPackage.LINK_MODEL__PACKAGE_CORRUPTION_PROBABILITY:
				setPackageCorruptionProbability(PACKAGE_CORRUPTION_PROBABILITY_EDEFAULT);
				return;
			case NetmodelPackage.LINK_MODEL__DELAY:
				setDelay(DELAY_EDEFAULT);
				return;
			case NetmodelPackage.LINK_MODEL__FAILURE_PROBABILITY:
				setFailureProbability(FAILURE_PROBABILITY_EDEFAULT);
				return;
			case NetmodelPackage.LINK_MODEL__FAILURE_DURATION_DISTRIBUTION:
				setFailureDurationDistribution((DistributionModel)null);
				return;
			case NetmodelPackage.LINK_MODEL__NAME:
				setName(NAME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case NetmodelPackage.LINK_MODEL__SOURCE:
				return source != null;
			case NetmodelPackage.LINK_MODEL__DESTINATION:
				return destination != null;
			case NetmodelPackage.LINK_MODEL__CAPACITY_DISTRIBUTION:
				return capacityDistribution != null;
			case NetmodelPackage.LINK_MODEL__PACKAGE_CORRUPTION_PROBABILITY:
				return packageCorruptionProbability != PACKAGE_CORRUPTION_PROBABILITY_EDEFAULT;
			case NetmodelPackage.LINK_MODEL__DELAY:
				return delay != DELAY_EDEFAULT;
			case NetmodelPackage.LINK_MODEL__FAILURE_PROBABILITY:
				return failureProbability != FAILURE_PROBABILITY_EDEFAULT;
			case NetmodelPackage.LINK_MODEL__FAILURE_DURATION_DISTRIBUTION:
				return failureDurationDistribution != null;
			case NetmodelPackage.LINK_MODEL__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (packageCorruptionProbability: ");
		result.append(packageCorruptionProbability);
		result.append(", delay: ");
		result.append(delay);
		result.append(", failureProbability: ");
		result.append(failureProbability);
		result.append(", name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //LinkModelImpl
